home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / trace / tcpdump-2.2.1 / gencode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-14  |  3.7 KB  |  157 lines

  1. /*
  2.  * Copyright (c) 1990 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that: (1) source code distributions
  7.  * retain the above copyright notice and this paragraph in its entirety, (2)
  8.  * distributions including binary code include the above copyright notice and
  9.  * this paragraph in its entirety in the documentation or other materials
  10.  * provided with the distribution, and (3) all advertising materials mentioning
  11.  * features or use of this software display the following acknowledgement:
  12.  * ``This product includes software developed by the University of California,
  13.  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14.  * the University nor the names of its contributors may be used to endorse
  15.  * or promote products derived from this software without specific prior
  16.  * written permission.
  17.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18.  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20.  *
  21.  * @(#) $Header: gencode.h,v 1.14 92/02/14 15:18:55 mccanne Exp $ (LBL)
  22.  */
  23.  
  24. /*
  25.  * filter.h must be included before this file.
  26.  */
  27.  
  28. /* Address qualifers. */
  29.  
  30. #define Q_HOST        1
  31. #define Q_NET        2
  32. #define Q_PORT        3
  33. #define Q_GATEWAY    4
  34. #define Q_PROTO        5
  35.  
  36. /* Protocol qualifiers. */
  37.  
  38. #define Q_LINK        1
  39. #define Q_IP        2
  40. #define Q_ARP        3
  41. #define Q_RARP        4
  42. #define Q_TCP        5
  43. #define Q_UDP        6
  44. #define Q_ICMP        7
  45.  
  46. /* Directional qualifers. */
  47.  
  48. #define Q_SRC        1
  49. #define Q_DST        2
  50. #define Q_OR        3
  51. #define Q_AND        4
  52.  
  53. #define Q_DEFAULT    0
  54. #define Q_UNDEF        255
  55.  
  56. struct stmt {
  57.     int code;
  58.     long k;
  59. };
  60.  
  61. struct slist {
  62.     struct stmt s;
  63.     struct slist *next;
  64. };
  65.  
  66. /* 
  67.  * A bit vector to represent definition sets.  We assume TOT_REGISTERS
  68.  * is smaller than 8*sizeof(atomset).
  69.  */
  70. typedef u_long atomset;
  71. #define ATOMMASK(n) (1 << (n))
  72. #define ATOMELEM(d, n) (d & ATOMMASK(n))
  73.  
  74. /*
  75.  * An unbounded set.
  76.  */
  77. typedef u_long *uset;
  78.  
  79. /*
  80.  * Total number of atomic entities, including accumulator (A) and index (X).
  81.  * We treat all these guys similarly during flow analysis.
  82.  */
  83. #define N_ATOMS (BPF_MEMWORDS+2)
  84.  
  85. struct edge {
  86.     int id;
  87.     int code;
  88.     uset edom;
  89.     struct block *succ;
  90.     struct block *pred;
  91.     struct edge *next;    /* link list of incoming edges for a node */
  92. };
  93.  
  94. struct block {
  95.     int id;
  96.     struct slist *stmts;    /* side effect stmts */
  97.     struct stmt s;        /* branch stmt */
  98.     int mark;
  99.     int level;
  100.     int offset;
  101.     int sense;
  102.     struct edge et;
  103.     struct edge ef;
  104.     struct block *head;
  105.     struct block *link;    /* link field used by optimizer */
  106.     uset dom;
  107.     uset closure;
  108.     struct edge *in_edges;
  109.     atomset def, kill;
  110.     atomset in_use;
  111.     atomset out_use;
  112.     long oval;
  113.     long val[N_ATOMS];
  114. };
  115.  
  116. struct arth {
  117.     struct block *b;    /* protocol checks */
  118.     struct slist *s;    /* stmt list */
  119.     int regno;        /* virtual register number of result */
  120. };
  121.  
  122. extern struct arth *gen_loadi();
  123. extern struct arth *gen_load();
  124. extern struct arth *gen_loadlen();
  125. extern struct arth *gen_neg();
  126. extern struct arth *gen_arth();
  127.  
  128. extern void gen_and();
  129. extern void gen_or();
  130. extern void gen_not();
  131.  
  132. extern struct block *gen_scode();
  133. extern struct block *gen_ecode();
  134. extern struct block *gen_ncode();
  135. extern struct block *gen_proto_abbrev();
  136. extern struct block *gen_relation();
  137. extern struct block *gen_less();
  138. extern struct block *gen_greater();
  139. extern struct block *gen_byteop();
  140. extern struct block *gen_broadcast();
  141. extern struct block *gen_multicast();
  142.  
  143. extern void optimize();
  144.  
  145. extern void finish_parse();
  146.  
  147. struct qual {
  148.     unsigned char addr;
  149.     unsigned char proto;
  150.     unsigned char dir;
  151.     unsigned char pad;
  152. };
  153.  
  154. /* XXX */
  155. #define JT(b)  ((b)->et.succ)
  156. #define JF(b)  ((b)->ef.succ)
  157.